<%--
  Created by IntelliJ IDEA.
  User: Lenovo
  Date: 2024/2/28
  Time: 10:56
  To change this template use File | Settings | File Templates.
--%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="f" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
</head>
<body>

<form method="get" action="${pageContext.request.contextPath}/user/list">

    登录名称：<input type="text" name="loginName">
    &nbsp;&nbsp;
    手机号码：<input type="text" name="phonenumber">
    &nbsp;&nbsp;
    用户状态：<select name="status">
    <option value="3" name="status">所有</option>
    <option value="0" name="status">正常</option>
    <option value="1" name="status">停用</option>
</select>

    <p>
        创建时间：<input type="date" name="createTime"/> 至 <input type="date" name="updateTime"/>
        &nbsp;&nbsp;<input type="submit" value="查询">
        &nbsp;&nbsp;<input type="reset" value="重置">

        <input style="margin-left: 130px" type="button"
               onclick="location.href='${pageContext.request.contextPath}/sysUser/toSysUserAdd'"
               value="添加">
    </p>

</form>


<div>
    <table border="1" cellspacing="0">
        <tr>
            <td>用户ID</td>
            <td>登录名称</td>
            <td>用户名称</td>
            <td>部门</td>
            <td>手机</td>
            <td>用户状态</td>
            <td>创建时间</td>
            <td colspan="2">操作</td>
        </tr>

        <c:forEach items="${sysUsers}" var="userList">
            <tr>
                <td>${userList.userId}</td>
                <td>${userList.loginName}</td>
                <td>${userList.userName}</td>
                <td>${userList.deptName}</td>
                <td>${userList.phonenumber}</td>
                <td><a href="javascript:void(0)"
                       onclick="reviseStatus(${userList.status})">${userList.status==0 ? '正常':'停用'}</a></td>
                <td><f:formatDate value="${userList.createTime}" pattern="yyyy-MM-dd HH:mm:ss"/></td>
                <td>
                    <a href="${pageContext.request.contextPath}/sysUser/toSysUserUpdate?userId=${userList.userId}">编辑</a>
                    <a href="#">删除</a>
                </td>
            </tr>
        </c:forEach>
    </table>

    <p>
        <a href="${pageContext.request.contextPath}/user/list?pageNo=1">首页</a>
        <a href="${pageContext.request.contextPath}/user/list?<c:if test="${pageNo!=1}">pageNo=${pageNo-1}</c:if>">上一页</a>
        ${pageNo}/${totalPages}
        <a href="${pageContext.request.contextPath}/user/list?<c:if test="${pageNo<totalPages}">pageNo=${pageNo+1}</c:if><c:if test="${pageNo==totalPages}">pageNo=${pageNo}</c:if>">下一页</a>
        <a href="${pageContext.request.contextPath}/user/list?pageNo=${totalPages}">末页</a>
        共有${count}条数据
    </p>

</div>

<script src="${pageContext.request.contextPath}/statics/js/jquery.min.js"></script>
<script>
    function reviseStatus(status) {
        if (confirm("确认要修改用户状态吗？")) {
            location.href = ""
        }
    }
</script>

</body>
</html>
